class HandGrenadeFire extends TFProjectileFire;

var() float         mSpeedMin;
var() float         mSpeedMax;
var() float         mHoldSpeedMin;
var() float         mHoldSpeedMax;
var() float         mHoldSpeedGainPerSec;
var() float         mHoldClampMax;
var() float         mWaitTime;

#exec OBJ LOAD FILE=..\Sounds\NewWeaponSounds.uax


function PostBeginPlay()
{
    Super.PostBeginPlay();
    mHoldClampMax = (mHoldSpeedMax - mHoldSpeedMin) / mHoldSpeedGainPerSec;
}

function projectile SpawnProjectile(Vector Start, Rotator Dir)
{
    local Projectile g;
    local vector X, Y, Z;
    local float pawnSpeed;

    g = Spawn(ProjectileClass,,, Start, Dir);
    if (g != None)
    {
        Weapon.GetViewAxes(X,Y,Z);
        pawnSpeed = X dot Instigator.Velocity;

		if ( Bot(Instigator.Controller) != None )
			g.Speed = mHoldSpeedMax;
		else
			g.Speed = mHoldSpeedMin + HoldTime*mHoldSpeedGainPerSec;
		g.Speed = FClamp(g.Speed, mHoldSpeedMin, mHoldSpeedMax);
        g.Speed = pawnSpeed + g.Speed;
        g.Velocity = g.Speed * Vector(Dir);
        g.Damage *= DamageAtten;

    }
    return g;
}

function PlayPreFire()   {}
function PlayStartHold() {}
function PlayFiring()    {}
function PlayFireEnd()   {}

simulated function ReturnToIdle()
{
    GotoState('Idle');
}

auto state Idle
{
    function StopFiring()
    {
        if (Instigator.Weapon != Weapon)
            return;

        if ( (Level.NetMode != NM_Client) && (Instigator.DrivenVehicle == None) )
            Weapon.PlaySound(FireSound,SLOT_Interact,TransientSoundVolume,,512.0,,false);

        ClientPlayForceFeedback(FireForce);  // jdf

        Super.StopFiring();
    }
}


function StartBerserk()
{
    mHoldSpeedGainPerSec = default.mHoldSpeedGainPerSec * 0.75;
    mHoldClampMax = (mHoldSpeedMax - mHoldSpeedMin) / mHoldSpeedGainPerSec;
}

function StopBerserk()
{
    mHoldSpeedGainPerSec = default.mHoldSpeedGainPerSec;
    mHoldClampMax = (mHoldSpeedMax - mHoldSpeedMin) / mHoldSpeedGainPerSec;
}

defaultproperties
{
     mSpeedMin=250.000000
     mSpeedMax=3000.000000
     mHoldSpeedMin=800.000000
     mHoldSpeedMax=1600.000000
     mHoldSpeedGainPerSec=800.000000
     ProjSpawnOffset=(X=25.000000,Y=10.000000,Z=-7.000000)
     bSplashDamage=True
     bRecommendSplashDamage=True
     bTossed=True
     bFireOnRelease=True
     FireLoopAnim=
     FireEndAnim=
     FireSound=Sound'NewWeaponSounds.NewGrenadeShoot'
     ReloadSound=Sound'WeaponSounds.BaseGunTech.BReload9'
     FireForce="AssaultRifleAltFire"
     ReloadForce="BReload9"
     FireRate=1.250000
     AmmoClass=Class'Taskforces.TGrenadeAmmo'
     AmmoPerFire=1
     ShakeRotTime=2.000000
     ShakeOffsetMag=(X=-20.000000)
     ShakeOffsetRate=(X=-1000.000000)
     ShakeOffsetTime=2.000000
     ProjectileClass=class'Taskforces.TGrenadeProj'
     BotRefireRate=0.250000
}
